#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main(int argc,char *argv[])
{
    char *tmp=argv[1];
    printf("agrv :%s %s\n",argv[0],argv[1]);
    if(tmp==NULL)
        return -1;
    int state=atoi(tmp);
    printf("state=%d\n",state);
    if(state!=0&&state!=1)
    {
        printf("using \"./gpio_led.app 0/1\" to set led off/on!\n");
        return -1;
    }
    int fd=open("/dev/gpio_led",O_WRONLY);
    if(fd<0)
        return -1;
    if(write(fd,tmp,2)<0)
        return -1;

    close(fd);
}